function [nrm] = chiSquared(u,v)
%Computes the Chi Squared distance of u and v 
    
    %Must be of same length
    assert(size(v,1)==size(u,1));
    
    %Assuming column vectors
    assert(size(u,2)==size(v,2) && size(v,2)==1);
    
    %Vectors must be non-negative
    assert(min(u) >= 0 && min(v) >= 0);
    
    %Vectors must sum to 1
    assert(sum(u)==1 && sum(v)==1);
    
    %Compute the Chi Squared distance
    nrm = .5*sum(((u-v).^2)./(u+v));
end
